﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WA.Utility;
using WA.Core.DaoInterfaces;
using WA.Core.DomainModel;

namespace WA.Core.Managers
{
    public class PartnersManager
    {
        IPartnerDao partnerDao;

        public PartnersManager()
        {

            // this concept is because you can set up dao implementations in 
            InvoicesDaoFactoryService service=new InvoicesDaoFactoryService();
            IDaoFactory daoFactory=service.GetDaoFactory();
            partnerDao=daoFactory.GetPartnerDao();
        }

        public List<Partner> GetAllPartners()
        {
            return partnerDao.GetAll();
        }

        public bool AddNewPartner(Partner partner)
        {
            try
            {
                partnerDao.Save(partner);               
                return true;
            }
            catch (Exception ex)
            {
                //logging exception should be performed here...
                return false;
            }
        }       

        public List<Partner> SearchPartnersByName(string name)
        {
            try
            {
                return partnerDao.GetPartnersByName(name);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


    }
}
